package com.dba.example.gwt.client.gin;

import javax.inject.Inject;

import com.dba.example.gwt.client.activities.AccountActivity;
import com.dba.example.gwt.client.activities.CompanyEditActivity;
import com.dba.example.gwt.client.activities.CompanyListActivity;
import com.dba.example.gwt.client.activities.HomeActivity;
import com.dba.example.gwt.client.places.AccountPlace;
import com.dba.example.gwt.client.places.CompanyEditPlace;
import com.dba.example.gwt.client.places.CompanyListPlace;
import com.dba.example.gwt.client.places.HomePlace;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {

	@Inject
	HomeActivity homeActivity;

	@Inject
	AccountActivity accountActivity;

	@Inject
	CompanyListActivity companyListActivity;
	
	@Inject
	CompanyEditActivity companyEditActivity;
	
	public AppActivityMapper() {
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof HomePlace) {
			homeActivity.setPlace((HomePlace) place);
			return homeActivity;
		}
		if (place instanceof AccountPlace) {
			accountActivity.setPlace((AccountPlace) place);
			return accountActivity;
		}
		if (place instanceof CompanyListPlace) {
			companyListActivity.setPlace((CompanyListPlace) place);
			return companyListActivity;
		}
		if (place instanceof CompanyEditPlace) {
			companyEditActivity.setPlace((CompanyEditPlace) place);
			return companyEditActivity;
		}
		return null;
	}
	
}